#!/usr/bin/python3
import shutil
import os
ip_file = "/etc/sysconfig/network-scripts/ifcfg-eno16777736"
shutil.copy(ip_file,"ip.txt")
ip = input("请输入ip:")
mask = input("请输入子网掩码:")
way = input("请输入网关:")
dns = input("请输入dns:")

with open('ip.txt','w+') as f:
    f.write("DEVICE=eno16777736\n")
    f.write("IPADDR=%s\n" %ip)
    f.write("NETMASK=%s\n" %mask)
    f.write("GETWAY=%s\n" %way)
    f.write("DNS1=%s\n" %dns)
os.system('service network restart')
